package mao.thinkinjava.concurency.daemon;

import java.util.concurrent.TimeUnit;
//后台进程不会run finally。
public class DaemonDontRunFinally {
    public static void main(String[] args) {
        Thread thread = new Thread(new ADeamon());
        //设置为true的话，前台线程结束，后台线程立马结束。
        thread.setDaemon(true);
        thread.start();
        try {
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            System.out.println("exit");
        }
    }
}
